	<?php

/**
 * Controller_position
 */

class Controller_position extends MyApp {


    /** 首页 **/
    public function actionIndex()
    {

         $this->tpl->display();
    }
	/** 教师职位列表 **/
    public function actionPositionList()
    {
        $position_lists = $this->db->fetchAll("SELECT * FROM `tbl_position`");
        $this->tpl->assign("position_lists", $dposition_lists);
        $this->tpl->display('position/position.list.tpl.php');     
    }
    /** 教师职位添加 **/
    public function actionPositionAdd()
    {        
        $position_lists = $this->db->fetchAll("SELECT * FROM `tbl_position`");
	
        if ($_POST){ 
            
            $position_name     	    = $this->post->position_name;
   
            // 写入数据库
            $info = array(       
			
            "position_name"      	=> $position_name,
            "status"                => 1,
            "create_time"           => date("Y-m-d H:i:s"),
            "update_time"           => "0000-00-00 00:00:00",  
			
            );
            $this->db->do_insert("tbl_position", $info);

            // 跳转
            Helper_Client::location("添加成功", "index.php?a=position.list&position_id={$position_id}");
        }
        
        $this->tpl->assign("position/position_lists", $position_lists);
        $this->tpl->display();
    }
    /** 教师职位修改 **/
    public function actionPositionUpdate()
    {
 
        $position_id   = (int)$this->get->position_id;
        $position_data = $this->db->fetchROW("SELECT * FROM `tbl_position` WHERE `position_id`='{$position_id}'");
	
        if (empty($position_data)){
            Helper_Client::alert("部门不存在");
        }

        if ($_POST){
            
            $position_name        = $this->post->position_name;
             
            // 写入数据库
            $info = array(  
    
            "position_name"      	=> $position_name,           
            
            "status"                => 1,
            "create_time"           => date("Y-m-d H:i:s"),
            "update_time"           => "0000-00-00 00:00:00",           
            );
            $this->db->do_update("tbl_position", $info, "position_id='{$position_id}'");
      
            // 跳转
            Helper_Client::location("修改成功", "index.php?a=position.list&position_id={$position_id}");
        }
    
        $this->tpl->assign("position/position_data", $position_data);
        $this->tpl->display();
    }
    /** 教师职位删除 **/
    public function actionPositionDel()
    {
        $position_id = $this->get->position_id;   
        $this->db->query("DELETE  FROM `tbl_position` WHERE position_id='{$position_id}'");
        
        // 跳转
        Helper_Client::location("删除成功", "index.php?a=position.list&position_id={$position_id}");
    }
    //**-------------------------------------------- 班干部 -----------------------------------------**//
   	/** 学生干部列表 **/
    public function actionStuLeaderList()
    {	
        $stuleader_lists = $this->db->fetchAll("SELECT * FROM `tbl_position`");
        $this->tpl->assign("stuleader_lists", $stuleader_lists);
        $this->tpl->display('position/position.list.tpl.php');     
    }
}
	
?>